﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace DScheme.DancerClasses
{
    class DancerActionMoveTo : DancerAction
    {
        protected PointD startPos;
        protected PointD destPos;

        public DancerActionMoveTo(Dancer dancer, Point destPos, double startTime, double moveTime)
            : base(dancer, startTime, moveTime)
        {
            this.destPos = destPos;
        }

        protected override void ExecuteBeforeStart()
        {
            startPos = dancer.Pos;
        }

        protected override void ExecuteAction(double actTime)
        {
            dancer.Pos = new PointD(startPos.X + (destPos.X - startPos.X) * DoneValue
                                  , startPos.Y + (destPos.Y - startPos.Y) * DoneValue);
        }

        protected override void ExecuteDone()
        {
            dancer.Pos = destPos;
        }
    }

    class DancerActionMoveOn : DancerActionMoveTo
    {
        double moveX;
        double moveY;

        public DancerActionMoveOn(Dancer dancer, double moveX, double moveY, double startTime, double moveTime)
            : base(dancer, new Point(), startTime, moveTime)
        {
            this.moveX = moveX;
            this.moveY = moveY;
        }

        protected override void ExecuteBeforeStart()
        {
            base.ExecuteBeforeStart();
            destPos = new PointD(startPos.X + moveX, startPos.Y + moveY);
        }
    }

}
